public class StrPerf {

	public static String PerfTick_01() {
//String str = 	" Hello "+" Hello "+" Hello " + 
//				" Hello "+" Hello "+" Hello " +
//				" Hello "+" Hello "+" Hello "+" Hello ";
		String str = "Hello "; 
		str += "Hello "; 
		str = str + "Hello " + "Hello " +"Hello " +"Hello "; 
		str += "Hello " + "Hello " +"Hello " +"Hello ";
		return str;
	}

	public static String PerfTick_02() {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < 10; i++, sb.append(" Hello "))
			;
		return sb.toString();
	}

	public static void main(String[] args) {
		long start_1 = 0;
		long start_2 = 0;
		long end_1 = 0;
		long end_2 = 0;

		for (int ii = 0; ii < 5; ii++) {

			start_1 = System.currentTimeMillis();
			for (int i = 0; i < 123450; i++)
				StrPerf.PerfTick_01();
			end_1 = System.currentTimeMillis();

			start_2 = System.currentTimeMillis();
			for (int i = 0; i < 123450; i++)
				StrPerf.PerfTick_02();
			end_2 = System.currentTimeMillis();

			System.out.println("Stri ng vs StringBuffer " + (end_1 - start_1) + " vs " + (end_2 - start_2));
		}// end for

	}
}